<template>
  <div class="list">
    <div class="xh">
      <span>猜你喜欢</span>
    </div>
    <div class="px">
      <span
        @click="gl(index)"
        :style="{ color: current == index ? 'red' : '' }"
        v-for="(item, index) in pxArr"
        :key="index"
        >{{ item }}</span
      >
    </div>
    <div class="rm">
      <span v-for="(item, index) in rmArr" :key="index">{{ item }}</span>
    </div>

    <div class="shop" v-for="(item, index) in shoplist" :key="index">
      <div class="img">
        <img :src="item.picUrl" alt="" />
      </div>
      <div class="spjs">
        <div class="name">
          <span>{{ item.name }}</span>
        </div>
        <div class="ys">
          <span>{{ item.monthSalesTip }}</span>
        </div>
        <div>
          <span>{{ item.minPriceTip }}</span>
          <span>{{ item.shippingFeeTip }}</span>
          <span>{{ item.deliveryTimeTip }}</span>
          <span>{{ item.distance }}</span>
        </div>
      </div>
    </div>
    <div class="kong"></div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      current: 0,
      pxArr: ["综合排序", "距离最近", "销量最高", "筛选"],
      rmArr: ["年货节热卖", "津贴联盟", "满减优惠", "品质联盟"],
      shoplist: [],
    };
  },
  mounted() {
    //
    axios.get("/api/shop/list").then((res) => {
      console.log(res.data);
      this.shoplist = res.data.list;
    });
  },
  methods: {
    gl(index) {
      this.current = index;
      if (index == 1) {
        this.shoplist.sort((a, b) => {
          return a.distance - b.distance;
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.list {
  padding: 10px;
}
.list .xh {
  font-size: 18px;
  font-weight: bold;
  padding-bottom: 10px;
}
.list .px {
  display: flex;
  justify-content: space-between;
  padding-bottom: 10px;
}
.list .rm {
  display: flex;
  justify-content: space-between;
}
.list .rm span {
  background: #f5f5f5;
  padding: 5px 10px;
  font-size: 14px;
  border-radius: 5px;
}
.list .shop {
  margin-top: 10px;
  height: 100px;
}
.list .shop .img {
  height: 100px;
  width: 100px;
  float: left;
  margin-right: 10px;
}
.list .shop .img img {
  width: 100%;
}
.list .kong {
  height: 40px;
}
</style>